/*
 * File Name: ViewComposite.java
 *------------------------------------------------------------------------------
 * Copyright 2012 NCR Corporation
 *------------------------------------------------------------------------------
 * All revision information is updated automatically from source code control
 * change records - please do not manually edit.
 *------------------------------------------------------------------------------
 *
 * $LastChangedRevision:: 1569                                     $
 * $LastChangedBy:: rb250096                                       $
 * $LastChangedDate:: 2012-02-21 00:50:19 -0500 (Tue, 21 Feb 2012) $
 */

package com.ncr.nep.dashboardcore.mvp.client;

import com.google.gwt.user.client.ui.Composite;

/**
 * {@link Composite} class that acts as a {@link View} in an MVP display 
 * hierarchy.  This composite provides a reference to the Presenter that events
 * and other UI interaction should be delegated to.
 *
 * @param <T> The type of {@link Presenter} used to manage the view
 *           {@link Composite}.
 * 
 * @author rb250096
 * @version $Revision: 1569 $
 */
@SuppressWarnings("rawtypes")
public abstract class ViewComposite<T extends Presenter> extends Composite
        implements View {

    /**
     * The {@link Presenter} associated with this view.  All UI interaction
     * logic involving the model is delegated to this object.
     */
    protected T presenter;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    @Override
    public Presenter<?> getPresenter() {
        return this.presenter;
    }

    @SuppressWarnings("unchecked")
    public void setPresenter(Presenter<?> presenter) {
        this.presenter = (T)presenter;
        this.presenter.setView(this);
    }
}
